import { createStore } from "vuex";

let defaultcity='杭州'
if (localStorage.city) {
	defaultcity=localStorage.city
}

export default createStore({
  state: {
	   cityname:defaultcity,type:1,cityid:0
  },
  mutations: {
	  changeCity(state,val){
		 state.cityname=val
		 localStorage.city=val
		 if (val=='杭州') {
		 	state.cityid=0
		 } else if(val=='北京'){
		 	state.cityid=1
		 }else if(val=='广州'){
		 	state.cityid=2
		 }
	  },
	  gettype(state,val){
	  	 state.type=val
	  }
  },
  actions: {
	  ajaxNum(context){
	  	  context.commit('Num')
	  }
  },
  modules: {},
});
